LOTTERY_AGGREGATE_REPORT = {
    'real_time_report': False,
    'group_by': 'cp_lottery_sub_type',
    'dynamic_argument': True,
    'interval_type_list': ['day'],
    'target_event_id': ['cp_lottery'],
    'values': [
        {
            "value_id": "participate_user",
            "target_value": "_user_id",
            "value_name": "投注账号",
            "filter": [],
            "value_type": "float",
            "operation": "cardinality"
        },
        {
            "value_id": "bet_amount",
            "target_value": "cp_lottery_price",
            "value_name": "投注金额",
            "filter": [
                {"term": {"cp_lottery_refund": 0}}
            ],
            "value_type": "float",
            "adjust_amount": True
        },
        {
            "value_id": "award_amount",
            "target_value": ['cp_lottery_win', '+', 'cp_lottery_bonus'],
            "value_name": "中奖金额",
            "filter": [
                {"term": {"cp_lottery_refund": 0}}
            ],
            "value_type": "float",
            "adjust_amount": True
        },
        {
            "value_id": "choushui",
            "target_value": ['cp_lottery_price', '-', 'cp_lottery_win', '-', 'cp_lottery_bonus'],
            "value_name": "玩法营收",
            "filter": [
                {"term": {"cp_lottery_refund": 0}}
            ],
            "value_type": "float",
            "adjust_amount": True
        },
        {
            "value_id": "choushui_rate",
            "value_name": "抽水率",
            "value_expr": "choushui/bet_amount",
            "is_percentage": True,
            "fmt": lambda v: float("%.2f" % (v * 100))
        },
        {
            "value_id": "profit_user_count",
            "target_value": "_user_id",
            "value_name": "盈利用户",
            "filter": [
                {"terms": {"_user_id": "${profit_user_pool}"}}
            ],
            "operation": "cardinality",
            "value_type": "long"
        },
        {
            "value_id": "profit_user_profit_amount",
            "target_value": "cp_lottery_profit",
            "value_name": "赢家盈亏",
            "filter": [
                {"term": {"_event_id": "cp_lottery"}},
                {"terms": {"_user_id": "${profit_user_pool}"}}
            ],
            "value_type": "float",
            "adjust_amount": True
        },
        {
            "value_id": "lose_user_count",
            "target_value": "_user_id",
            "value_name": "亏损用户",
            "filter": [
                {"terms": {"_user_id": "${lose_user_pool}"}}
            ],
            "operation": "cardinality",
            "value_type": "long"
        },
        {
            "value_id": "lose_user_lose_amount",
            "target_value": "cp_lottery_profit",
            "value_name": "输家盈亏",
            "filter": [
                {"term": {"_event_id": "cp_lottery"}},
                {"terms": {"_user_id": "${lose_user_pool}"}}
            ],
            "value_type": "float",
            "adjust_amount": True
        }
    ]
}
